<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">产品前筛规则列表</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton value="批量模式"
                                         icon="fa fa-list-ul"
                                         actionListener="#{loanProductPrefilterListBean.changeModeToBatch}"
                                         update="@form"
                                         process="@this"
                                         rendered="#{loanProductPrefilterListBean.isNotBatch()}"/>
                        <p:commandButton value="常规模式" icon="fa fa-file"
                                         actionListener="#{loanProductPrefilterListBean.changeModeToNormal}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{loanProductPrefilterListBean.isBatch()}"/>
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="productPrefilterDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{loanProductPrefilterListBean.isNormal()}"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{loanProductPrefilterListBean.onReset}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{loanProductPrefilterListBean.isNormal()}"/>
                        <p:commandButton icon="fa fa-plus" value="新增"
                                         action="#{loanProductPrefilterListBean.onAdd}"
                                         rendered="#{loanProductPrefilterListBean.isNormal()}">
                            <f:setPropertyActionListener value="/views/product/prefilter/list.xhtml"
                                                         target="#{currentUserBean.back}"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-g ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12">
                    <div class="ui-g-12 card">
                        <h1>查询条件</h1>
                        <div class="ui-g-1">
                            <p:outputLabel value="规则名称"/>
                        </div>
                        <div class="ui-g-3">
                            <p:inputText value="#{loanProductPrefilterListBean.$.name}"/>
                        </div>
                    </div>

                    <div class="ui-g-12 card">
                        <p:dataTable id="productPrefilterDataTable"
                                     style="width: 100%"
                                     var="productPrefilter"
                                     value="#{loanProductPrefilterListBean.lazyDataModel}"
                                     rows="#{constants:get('ROWS')}"
                                     lazy="true"
                                     paginator="true"
                                     paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                     rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                     emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                     scrollable="true"
                                     scrollWidth="97%"
                                     reflow="true"
                                     selection="#{loanProductPrefilterListBean.selectedRecords}"
                                     resizableColumns="true">


                            <p:column headerText="操作" rendered="#{loanProductPrefilterListBean.isNotBatch()}"
                                      style="width: 100px">
                                <p:splitButton icon="fa fa-eye"
                                               action="#{loanProductPrefilterListBean.onEdit(productPrefilter.id)}"
                                               process="@this">
                                    <f:setPropertyActionListener
                                            value="/views/product/prefilter/list.xhtml"
                                            target="#{currentUserBean.back}"/>
                                </p:splitButton>
                            </p:column>
                            <p:column headerText="规则名称">
                                <h:outputText value="#{productPrefilter.name}"/>
                            </p:column>
                            <p:column headerText="创建人">
                                <h:outputText value="#{productPrefilter.creator}"/>
                            </p:column>
                            <p:column headerText="创建时间">
                                <h:outputText value="#{productPrefilter.createTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="更新人">
                                <h:outputText value="#{productPrefilter.updator}"/>
                            </p:column>
                            <p:column headerText="更新时间">
                                <h:outputText value="#{productPrefilter.updateTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                        </p:dataTable>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
